package com.example.cloud.stream.rabbitmq.consumer.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * 消息接收者
 *
 * @author Frank
 * @create 2020-12-06 20:39
 * 启动绑定，就是表示当前类是sink，负责接收channel发送过来的数据进行消费
 **/
@Slf4j
@Component
@EnableBinding(Sink.class)
public class ReceiveMessageListenerController {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT)
    public void input(Message<String> message) {
        log.info("消费者1号，----->接收到的消息： " + message.getPayload() + "\t port: " + serverPort);

    }
}
